package model.agent.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import model.agent.entity.Agent;
import model.agent.entity.Personnel;
import model.agent.entity.Result;
import model.agent.service.IAgentService;
import model.agent.service.IPersonnelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by Administrator on 2019/6/25.
 */
@RestController
public class AgentController {
    @Autowired
    private IAgentService iAgentService;
    @Autowired
    private IPersonnelService personnelService;
//    @CrossOrigin
//   @GetMapping("/agent/{pageNow}")
//   public Result list(@PathVariable("pageNow") String pageNow){
//
//       Integer pg=Integer.parseInt(pageNow);
//        PageHelper.startPage(pg,6);
//        List<Agent> agentList=iAgentService.findall("");
//        PageInfo<Agent> pageInfo=new PageInfo<>(agentList);
//        Result result = new Result(true,20000,"查询成功",agentList);
//
//       return  result;
//   }
//    @CrossOrigin
//    @GetMapping("/agent")
//    public Result find(){
//
//        List<Agent> agentList=iAgentService.findall("");
//
//        Result result = new Result(true,20000,"查询成功",agentList);
//        return result;
//    }
//    @CrossOrigin
//    @DeleteMapping ("/agent/{name}")
//     public Result del(@PathVariable("name")String name){
//      iAgentService.del(name);
//        Result result = new Result(true,20000,"删除成功");
//       return result;
//    }
//    @CrossOrigin
//    @GetMapping("/address/{address}")
//    public Result findaddress(@PathVariable("address") String address){
//        List<Agent> agentList=iAgentService.getByAddress(address);
//
//        Result result = new Result(true,20000,"查询成功",agentList);
//
//        return  result;
//    }
@CrossOrigin
@GetMapping("/newagent/{address}")
public Result findaddrssslist(@PathVariable("address")String address){

    List<Agent> agentList=iAgentService.getByAddress(address);
    Result result = new Result(true,20000,"查询成功",agentList);
    return result;
}
    @CrossOrigin
    @GetMapping("/newagent")
    public Result findaddrsss(){

        List<Agent> agentList=iAgentService.getByAddress("");
        System.out.println(agentList);
        Result result = new Result(true,20000,"查询成功",agentList);
        System.out.println(result);
        System.out.println(result.getData());
        return result;
    }
    @CrossOrigin
    @GetMapping("/personel/{id}")
    public Result findaddrssslist1(@PathVariable("id")String id){

        List<Personnel> agentList=personnelService.find(id);
        Result result = new Result(true,20000,"查询成功",agentList);
        return result;
    }
    @CrossOrigin
    @GetMapping("/personel")
    public Result findaddrsss1(){

        List<Personnel> agentList=personnelService.find("");
        Result result = new Result(true,20000,"查询成功",agentList);
        return result;
    }
    @CrossOrigin
    @GetMapping("/sort")
    public Result findsort(){

        List<Agent> agentList=iAgentService.findsort();
        Result result = new Result(true,20000,"查询成功",agentList);
        return result;
    }
}
